<template>
  <a-modal
  :title="title"
  :width="1200"
  :visible="workListView"
  :confirmLoading="false"
  @ok="handleCancel"
  @cancel="handleCancel"
  cancelText="关闭">
    <a-card :bordered="false">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="劳动者姓名">
                <a-input placeholder="请输入劳动者姓名" v-model="queryParam.name"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="手机号">
                <a-input placeholder="请输入手机号" v-model="queryParam.mobile"></a-input>
              </a-form-item>
            </a-col>
            <template v-if="toggleSearchStatus">
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="身份证">
                  <a-input placeholder="请输入身份证" v-model="queryParam.idCard"></a-input>
                </a-form-item>
              </a-col>
              <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item label="劳动者来源地">
                  <a-input placeholder="请输入劳动者来源地" v-model="queryParam.sourceAddress"></a-input>
                </a-form-item>
              </a-col>-->
            </template>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->

      <!-- table区域-begin -->
      <div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>

        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          class="j-table-force-nowrap"
          @change="handleTableChange">

          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>

          <span slot="action" slot-scope="text, record">
            <a @click="handleSelect(record)">选择</a>
          </span>

        </a-table>
      </div>

      <emp-work-modal ref="modalForm" @ok="modalFormOk"></emp-work-modal>
    </a-card>
  </a-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import EmpWorkModal from '@/views/crm/empwork/modules/EmpWorkModal'


  export default {
    name: 'workListView',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      EmpWorkModal
    },
    data () {
      return {
        description: '劳动者个人信息表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'劳动者姓名',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'手机号',
            align:"center",
            dataIndex: 'mobile'
          },
          {
            title:'身份证',
            align:"center",
            dataIndex: 'idCard'
          },
          {
            title:'年龄',
            align:"center",
            dataIndex: 'age'
          },
          {
            title:'性别',
            align:"center",
            dataIndex: 'sex'
          },
          {
            title:'劳动者来源地',
            align:"center",
            dataIndex: 'sourceAddress'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/empWork/getLists"

        },
        title:'搜索劳动者',
        dictOptions:{},
        superFieldList:[],
        workListView:false,
        parent:{}
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    props:["row"],
    methods: {
      initDictConfig(){
      },
      showViewWorkList(parent) {
        this.parent = parent;
        this.workListView = true;
      },
      handleCancel(){
        this.workListView = false;
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'name',text:'劳动者姓名',dictCode:''})
        fieldList.push({type:'string',value:'mobile',text:'手机号',dictCode:''})
        fieldList.push({type:'int',value:'idCard',text:'身份证',dictCode:''})
        fieldList.push({type:'int',value:'age',text:'年龄',dictCode:''})
        fieldList.push({type:'string',value:'sex',text:'性别',dictCode:''})
        fieldList.push({type:'string',value:'sourceAddress',text:'劳动者来源地',dictCode:''})
        fieldList.push({type:'string',value:'sourceAddressCode',text:'劳动者来源地编码',dictCode:''})
        fieldList.push({type:'string',value:'relationId',text:'劳动者关系表ID',dictCode:''})
        this.superFieldList = fieldList
      },
      handleSelect(row){
        this.$emit("workerChanged",row);
        this.workListView = false;

      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>